home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / byteibm.arc / WILTON.ARC / CSETS.LST next >
Encoding:
File List  |  1985-07-12  |  13.9 KB  |  530 lines

  1.  
  2. Listing 1.
  3.  
  4.  
  5. 210 DEFINT A-Z
  6. 220 SCREEN 2 : CLS
  7. 230 FOR I = 0 TO 3*80 STEP 80           ' rows are 80 bytes apart
  8. 240  FOR S = &HB800 TO &HBA00 STEP &H200      ' even rows in B800
  9. 250   DEF SEG = S                              ' odd rows in BA00
  10. 260   READ B
  11. 270   POKE I,B                ' store each byte into video buffer
  12. 280   NEXT S
  13. 290  NEXT
  14. 300 PRINT : PRINT
  15. 310 END
  16. 320 '
  17. 330 'dot data which defines the character 'A' ...
  18. 340 DATA &h18,&h3c,&h66,&h66,&h7e,&h66,&h66,&h66
  19.  
  20.  
  21.  
  22. Listing 2.
  23.  
  24.  
  25. ; definitions for 8 by 8 characters 80h through FFh
  26. csdefs    db    087h,033h,03Fh,033h,087h,0E7h,0F3h,087h        ; 080h
  27.     db    0FFh,099h,0FFh,099h,099h,099h,0C0h,0FFh        ; 081h
  28.     db    0F1h,0FFh,0C3h,099h,081h,09Fh,0C3h,0FFh        ; 082h
  29.     db    081h,03Ch,0C3h,0F9h,0C1h,099h,0C0h,0FFh        ; 083h
  30.  
  31.                               .
  32.                               .
  33.                               .
  34.     db    087h,093h,093h,093h,093h,0FFh,0FFh,0FFh        ; 0FCh
  35.     db    08Fh,0E7h,0CFh,09Fh,087h,0FFh,0FFh,0FFh        ; 0FDh
  36.     db    0FFh,0FFh,0C3h,0C3h,0C3h,0C3h,0FFh,0FFh        ; 0FEh
  37.     db    0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh        ; 0FFh
  38.  
  39.  
  40. ; put CGA into All Points Addressible graphics mode so that DOS will use
  41. ; our character table
  42.     mov    al,6            ; 640x200 2color APA graphics
  43.     mov    ah,0
  44.     int    10h
  45.  
  46. ; point CGA graphics character generator to our character definitions
  47.     mov    dx,offset csdefs
  48.     push    cs
  49.     pop    ds            ; DS:DX points to our table
  50.     mov    al,1Fh            ; interrupt number
  51.     mov    ah,25h            ; DOS function number
  52.     int    21h
  53.  
  54.  
  55.  
  56.  
  57. Listing 3.
  58.  
  59.  
  60. ; definitions for 8 by 8 characters 00h through FFh
  61. csdefs    db    0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh        ; 000h
  62.     db    081h,07Eh,05Ah,07Eh,042h,066h,07Eh,081h        ; 001h
  63.     db    081h,000h,024h,000h,03Ch,018h,000h,081h        ; 002h
  64.     db    093h,001h,001h,001h,083h,0C7h,0EFh,0FFh        ; 003h
  65.                 .
  66.                 .
  67.                 .
  68.     db    089h,023h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh        ; 07Eh
  69.     db    0FFh,0EFh,0C7h,093h,039h,039h,001h,0FFh        ; 07Fh
  70. hi_half    db    087h,033h,03Fh,033h,087h,0E7h,0F3h,087h        ; 080h
  71.     db    0FFh,099h,0FFh,099h,099h,099h,0C0h,0FFh        ; 081h
  72.                 .
  73.                 .
  74.                 .
  75.     db    087h,093h,093h,093h,093h,0FFh,0FFh,0FFh        ; 0FCh
  76.     db    08Fh,0E7h,0CFh,09Fh,087h,0FFh,0FFh,0FFh        ; 0FDh
  77.     db    0FFh,0FFh,0C3h,0C3h,0C3h,0C3h,0FFh,0FFh        ; 0FEh
  78.     db    0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh        ; 0FFh
  79.  
  80.  
  81. ; put EGA into All Points Addressible graphics mode so that DOS will use
  82. ; our character table
  83.     mov    al,6            ; 640x200 2color APA graphics
  84.     mov    ah,0
  85.     int    10h
  86.  
  87. ; point EGA graphics character generator to our character definitions
  88.     mov    bp,offset csdefs
  89.     push    cs
  90.     pop    es            ; ES:BP points to our table
  91.     mov    cx,8            ; CX := bytes/character in table
  92. è    mov    bl,0            ; BL := 0 (BIOS will use DL for
  93.                     ;  number of rows on screen)
  94.     mov    dl,19h            ; DL := 25 (number of character rows
  95.                     ;  on screen)
  96.     mov    al,21h            ; "user graphics character load"
  97.     mov    ah,11h            ; BIOS "character generator routine"
  98.     int    10h            ; call EGA BIOS
  99.  
  100. ; for compatibility, point interrupt 1Fh vector to characters 80h - FFh
  101.     mov    bp,offset hi_half
  102.     push    cs
  103.     pop    es            ; ES:BP -> 2nd half of table
  104.     mov    al,20h            ; "int 1Fh load"
  105.     mov    ah,11h
  106.     int    10h
  107.  
  108.  
  109.  
  110.  
  111. Listing 4.
  112.  
  113. ; definitions for 8 by 8 characters 00h through FFh
  114. csdefs    db    0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh        ; 000h
  115.     db    081h,07Eh,05Ah,07Eh,042h,066h,07Eh,081h        ; 001h
  116.     db    081h,000h,024h,000h,03Ch,018h,000h,081h        ; 002h
  117.     db    093h,001h,001h,001h,083h,0C7h,0EFh,0FFh        ; 003h
  118.                 .
  119.                 .
  120.                 .
  121.     db    087h,093h,093h,093h,093h,0FFh,0FFh,0FFh        ; 0FCh
  122.     db    08Fh,0E7h,0CFh,09Fh,087h,0FFh,0FFh,0FFh        ; 0FDh
  123.     db    0FFh,0FFh,0C3h,0C3h,0C3h,0C3h,0FFh,0FFh        ; 0FEh
  124.     db    0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh        ; 0FFh
  125.  
  126.  
  127. ; call BIOS to copy our definitions into character generator RAM area in
  128. ; bit plane 2
  129.     mov    bp,offset csdefs
  130.     push    cs
  131.     pop    es            ; ES:BP points to our table
  132.     mov    cx,256            ; CX := number of characters defined
  133.                     ;  in table
  134.     mov    dx,0            ; DX := character offset in table
  135.     mov    bl,0            ; BL := number of table to load (must
  136.                     ;  be 0-3)
  137.     mov    bh,8            ; BH := # bytes/character in table
  138.     mov    al,10h            ; "user alpha load"
  139. è    mov    ah,11h            ; BIOS "character generator routine"
  140.     int    10h            ; call EGA BIOS
  141.  
  142. ; update BIOS RAM area in segment 40h
  143.     mov    ax,40h
  144.     mov    ds,ax
  145.  
  146.     mov    word ptr ds:[4Ah],80    ; update CRT_COLS (number of character
  147.                     ;  columns on the display)
  148.     mov    word ptr ds:[4Ch],1C00h    ; update CRT_LEN (80 rows * 43 columns
  149.                     ;  * 2 bytes/character, rounded up to
  150.                     ;  next even 1K boundary)
  151.  
  152.  
  153. Listing 5.
  154.  
  155. csdefs    db    000h,000h,000h,000h,000h,000h,000h,000h        ; 000h
  156.     db    8 dup(0)
  157. è    db    07Eh,081h,0A5h,081h,0BDh,099h,081h,07Eh        ; 001h
  158.     db    8 dup(0)
  159.     db    07Eh,0FFh,0DBh,0FFh,0C3h,0E7h,0FFh,07Eh        ; 002h
  160.     db    8 dup(0)
  161.                 .
  162.                 .
  163.                 .
  164.  
  165.     db    070h,018h,030h,060h,078h,000h,000h,000h        ; 0FDh
  166.     db    8 dup(0)
  167.     db    000h,000h,03Ch,03Ch,03Ch,03Ch,000h,000h        ; 0FEh
  168.     db    8 dup(0)
  169.     db    000h,000h,000h,000h,000h,000h,000h,000h        ; 0FFh
  170.     db    8 dup(0)
  171.  
  172.  
  173. ; set configuration switch on HGC Plus
  174.     mov    dx,3BFh            ; i/o port address
  175.     mov    al,1            ; activate RAM from B000:0000
  176.     out    dx,al            ;  through B000:7FFF
  177.  
  178. ; copy character definition table to B000:4000
  179.     mov    ax,0B000h
  180.     mov    es,ax
  181.     mov    di,4000h        ; ES:DI := B000:4000
  182.  
  183.     push    cs
  184.     pop    ds
  185.     mov    si,offset csdefs    ; DS:SI -> our character def table
  186.  
  187.     mov    cx,4096            ; CX := size of table in bytes
  188.     rep    movsb            ; copy the table
  189.  
  190. ; Program the CRT controller to display 43 lines of 8 by 8 characters.
  191. ; Characters are displayed in a 9x8 matrix for better appearance.
  192. ;
  193.     mov    dx,3B4h            ; CRT controller register index port
  194.  
  195.     mov    si,offset regs00_0D    ; DS:SI -> start of table of register
  196.                     ;  values
  197.  
  198.     mov    cx,0Eh            ; CX := loop counter
  199.     xor    ah,ah            ; AH := 0 (initial CRT controller
  200.                     ;  register number)
  201. label2:    mov    al,ah
  202.     out    dx,al            ; store CRT controller index reg
  203.     
  204.     lodsb                ; AL := data for CRT controller reg
  205.     inc    dx            ; DX := 3B5h (CRT data reg port)
  206.     out    dx,al            ; store data to CRT controller reg
  207.     dec    dx            ; DX := 3B4h
  208.  
  209. è    inc    ah            ; AH := next CRT controller index #
  210.     loop    label2
  211.  
  212.     mov    al,14h            ; xModeReg index number
  213.     out    dx,al
  214.  
  215.     lodsb
  216.     inc    dx
  217.     out    dx,al            ; configure xModeReg for RAM character
  218.                     ;  set and proper character width
  219.  
  220. ; update BIOS RAM area in segment 40h
  221.     mov    ax,40h
  222.     mov    ds,ax
  223.  
  224.     mov    word ptr ds:[4Ah],80    ; update CRT_COLS (80 columns)
  225.     mov    word ptr ds:[4Ch],1C00h    ; update CRT_LEN (80 columns * 43 rows
  226.                     ;  * 2 bytes/character, rounded up to
  227.                     ;  even 1K boundary)
  228.  
  229.                 .
  230.                 .
  231.                 .
  232.  
  233. ; table of CRT controller register values
  234.  
  235. regs00_0D    db    61h,50h,52h,0Fh        ; regs 0 - 3 (9 wide)
  236.         db    2Dh,02h,2Bh,2Ch        ; regs 4 - 7 (8 high)
  237.         db    02h,07h,06h,07h        ; regs 8 - 0Bh (scans/char,
  238.                         ;  cursor location)
  239.         db    00h,00h            ; regs 0Ch - 0Dh (always zero)
  240.  
  241. xModeReg    db    01h            ; "4K RamFont", 9 dot wide
  242.                         ;  characters
  243.  
  244.  
  245.  
  246. Listing 6.
  247.  
  248. cset0    equ    0            ; character generator RAM bank #'s
  249. cset1    equ    1
  250.                 .
  251.                 .
  252.                 .
  253.  
  254.  
  255. ; 1st 256 characters are 9x14 ROM characters (default for 350-line display)
  256.     mov    bl,cset0        ; indicate bank 0 of char generator RAM
  257.                     ;  (A000:0000 in bit plane 2)
  258.     mov    al,1            ; indicate 8x14 ROM characters
  259.     mov    ah,11h
  260.     int    10h            ; call BIOS to load character table
  261.  
  262. ; 2nd 256 characters are 8x8 ROM character set
  263.     mov    bl,cset1        ; indicate bank 1 of char gen RAM
  264.                     ;  (A000:4000 in bit plane 2)
  265.     mov    al,2            ; indicate 8x8 ROM characters
  266.     mov    ah,11h
  267.     int    10h
  268.  
  269. ; Enable attribute bit 3 selection of character set
  270.     mov    bl,(cset1 shl 2)+cset0    ; BL := value for Sequencer Character
  271.                     ;  Map Select register
  272.     mov    al,3            ; "set block specifier"
  273.     mov    ah,11h
  274.     int    10h            ; call BIOS to program Sequencer
  275.  
  276. ; Disable bit 3 of attribute byte for palette selection
  277.     mov    bh,7            ; bit mask
  278.     mov    bl,12h            ; Attribute Controller: Color Plane
  279.                     ;  Enable register number
  280.     mov    al,0            ; "individual palette register"
  281.     mov    ah,10h
  282.     int    10h            ; call BIOS to set register
  283.  
  284. ; Display a message
  285.     push    cs    
  286.     pop    ds
  287.  
  288.     mov    si,offset csmsg0
  289.     mov    bl,7            ; bit 3 of attribute = 0
  290.     mov    cx,25            ; length of string
  291.     call    show            ; display string using char set 0
  292.  
  293. è
  294.     mov    si,offset csmsg1
  295.     mov    bl,0Fh            ; bit 3 of attribute = 1
  296.     mov    cx,25
  297.     call    show            ; display string using char set 1
  298.                 .
  299.                 .
  300.                 .
  301.  
  302.  
  303. ; Subroutine which displays a string using a given attribute
  304.  
  305. show    proc    near            ; Caller:    DS:SI -> string
  306.                     ;        CX = length of string
  307.                     ;        BL = attribute
  308.     jcxz    show2
  309.  
  310. show1:    lodsb                ; AL := next char
  311.     push    cx
  312.     push    bx
  313.     call    emit            ; display this character
  314.     pop    bx
  315.     pop    cx
  316.     loop    show1
  317.  
  318. show2:    ret
  319.  
  320. show    endp
  321.  
  322.  
  323. ; Subroutine which displays a single character using a given attribute
  324.  
  325. emit    proc    near            ; Caller:    AL = character
  326.                     ;        BL = attribute
  327.                     ; Returns:    nothing, but advances
  328.                     ;         the cursor
  329.     push    bx
  330.     push    cx
  331.  
  332.     cmp    al,20h
  333.     jb    emit1            ; jump if control character
  334.  
  335.     push    ax            ; save char on stack
  336.     mov    cx,1            ; CX := # of chars to write
  337.     mov    bh,0            ; BH := video display page 0
  338.     mov    ah,9            ; call BIOS to write attribute and
  339.     int    10h            ;  character at cursor
  340.     pop    ax            ; AL := character
  341.  
  342. emit1:    mov    ah,0Eh            ; call BIOS to rewrite character in
  343.     int    10h            ;  "teletype mode" which advances
  344.                     ;  the cursor
  345.     pop    cx
  346. è    pop    bx
  347.     ret
  348.  
  349. emit    endp
  350.  
  351.  
  352. ; Strings to be displayed
  353.  
  354. csmsg0    db    'This is character set 0',0Dh,0Ah
  355. csmsg1    db    'This is character set 1',0Dh,0Ah
  356.  
  357.  
  358.  
  359. Listing 7.
  360.  
  361. ; set configuration switch on HGC Plus
  362. label0:    mov    dx,3BFh            ; i/o port address
  363.     mov    al,1            ; activate RAM from B000:0000
  364.     out    dx,al            ;  through B000:7FFF
  365.  
  366. ; Copy 1st 256 character definitions into character generator RAM from BIOS ROM
  367.     mov    ax,0F000h
  368.     mov    ds,ax
  369.     mov    si,0FA6Eh        ; DS:SI -> start of 8x8 character
  370.                     ;  definition table in ROM
  371.     mov    ax,0B000h
  372.     mov    es,ax
  373.     mov    di,4000h        ; ES:DI -> start of Hercules font
  374. è                    ;  definition storage area
  375.  
  376.     xor    al,al            ; AL := zero byte (used for padding)
  377.     mov    cx,256            ; CX := # of characters in table
  378.  
  379. label1:    push    cx            ; preserve loop counter
  380.  
  381.     mov    cx,8            ; CX := # of bytes in one character
  382.                     ;  definition
  383.     rep    movsb            ; copy to HGC font storage area
  384.  
  385.     mov    cx,8            ; CX := # of bytes of padding
  386.     rep    stosb            ; store zeroes
  387.  
  388.     pop    cx            ; loop across all 256 characters
  389.     loop    label1
  390.  
  391. ; Copy 2nd 256 character definitions into character generator RAM
  392.     mov    ax,0B000h
  393.     mov    ds,ax
  394.     mov    si,4000h        ; DS:SI -> start of 8x8 character
  395.                     ;  definition table in HGC Plus RAM
  396.     mov    cx,256*16        ; CX := size of 256-character table
  397.  
  398. label2:    lodsb                ; copy "reverse" of 1st 256 chars ...
  399.     not    al
  400.     stosb                ; .. into table for 2nd 256 chars
  401.     loop    label2
  402.  
  403. ; Program the CRT controller to display 25 lines of 8 by 14 characters.
  404.     mov    dx,3B4h            ; CRT controller register index port
  405.  
  406.     push    cs
  407.     pop    ds
  408.     mov    si,offset regs00_0D    ; DS:SI -> start of table of register
  409.                     ;  values
  410.  
  411.     mov    cx,0Eh            ; CX := loop counter
  412.     xor    ah,ah            ; AH := 0 (initial CRT controller
  413.                     ;  register number)
  414. label3:    mov    al,ah
  415.     out    dx,al            ; store CRT controller index reg
  416.     
  417.     lodsb                ; AL := data for CRT controller reg
  418.     inc    dx            ; DX := 3B5h (CRT data reg port)
  419.     out    dx,al            ; store data to CRT controller reg
  420.     dec    dx            ; DX := 3B4h
  421.  
  422.     inc    ah            ; AH := next CRT controller index #
  423.     loop    label3
  424.  
  425.     mov    cx,3
  426.     mov    ah,14h            ; index value for xModeReg
  427.  
  428. label4:    mov    al,ah            ; Same loop for extra CRT controller ..
  429. è    out    dx,al            ; .. regs used with extended ..
  430.                     ; .. character set
  431.     lodsb
  432.     inc    dx
  433.     out    dx,al
  434.     dec    dx
  435.  
  436.     inc    ah
  437.     loop    label4
  438.  
  439. ; Update BIOS RAM area in segment 40h
  440.     mov    ax,40h
  441.     mov    ds,ax
  442.     mov    word ptr ds:[4Ah],90    ; CRT_COLS := 90
  443.     mov    word ptr ds:[4Ch],1400h    ; CRT_LEN := 90 columns * 25 rows
  444.                     ;  * 2 bytes/char, rounded up to next
  445.                     ;  higher 1K
  446. ; Display a message
  447.     push    cs
  448.     pop    ds
  449.     mov    dx,1859h        ; use BIOS scroll routine ...
  450.     mov    cx,0            ; .. to set attribute bytes in ..
  451.     mov    bh,0            ; .. display buffer to zero
  452.     mov    ax,600h
  453.     int    10h
  454.  
  455.     mov    si,offset csmsg0    ; 1st message
  456.     mov    bl,0            ; BL (high nibble) := 0 (normal attrib)
  457.                     ; BL (low nibble) := 0 (1st 256 chars)
  458.     mov    cx,48            ; length of string
  459.     call    show            ; display string using char set 0
  460.  
  461.  
  462.     mov    si,offset csmsg1    ; 2nd message
  463.     mov    bl,81h            ; BL (hi nibble) := 8 (intense video)
  464.                     ; BL (lo nibble) := 1 (2nd 256 chars)
  465.     mov    cx,49
  466.     call    show            ; display string using char set 1
  467.  
  468.                 .
  469.                 .
  470.                 .
  471.  
  472.  
  473. ; Subroutine which displays a string using a given attribute
  474.  
  475. show    proc    near            ; Caller:    DS:SI -> string
  476.                     ;        CX = length of string
  477.                     ;        BL = attribute
  478.     jcxz    show2
  479.  
  480. show1:    lodsb                ; AL := next char
  481.     call    emit            ; display this character
  482.     loop    show1
  483.  
  484. show2:    ret
  485.  
  486. show    endp
  487.  
  488.  
  489. ; Subroutine which displays a single character using a given attribute
  490. ; Bits 0-3 of the attribute byte and bits 0-7 of the character form an
  491. ; 12-bit extended character code. Bits 4-7 of the attribute byte determine
  492. ; the actual attribute displayed.
  493.  
  494. emit    proc    near            ; Caller:    AL = character
  495.                     ;        BL = attribute
  496.                     ; Returns:    nothing, but advances
  497.                     ;         the cursor
  498.     push    bx
  499.     push    cx
  500.  
  501.     cmp    al,20h
  502.     jb    emit1            ; jump if control character
  503.  
  504.     push    ax            ; save char on stack
  505.     mov    cx,1            ; CX := # of chars to write
  506.     mov    bh,0            ; BH := video display page 0
  507.     mov    ah,9            ; call BIOS to write attribute and
  508.     int    10h            ;  character at cursor
  509.     pop    ax            ; AL := character
  510.  
  511. emit1:    mov    ah,0Eh            ; call BIOS to rewrite character in
  512.     int    10h            ;  "teletype mode" which advances
  513.                     ;  the cursor
  514.     pop    cx
  515.     pop    bx
  516.     ret
  517.  
  518. emit    endp
  519. è
  520.  
  521. ; table of CRT controller register values
  522.  
  523. regs00_0D    db    6Dh,5Ah,5Ch,0Fh        ; regs 0 - 3 (8 wide)
  524.         db    19h,06h,19h,19h        ; regs 4 - 7 (14 high)
  525.         db    02h,0Dh,0Ch,0Dh        ; regs 8 - 0Bh (scans/char,
  526.                         ;  cursor location)
  527.         db    00h,00h            ; regs 0Ch - 0Dh (always zero)
  528.  
  529. xModeReg    db    07h            ; "48K RamFont", 8 dot wide
  530.                         ;  characters
  531. ScoreReg    db    0Dh            ; underscore reg
  532. StrikeReg    db    06h            ; overstrike reg
  533.  
  534. ; Strings to be displayed
  535.  
  536. csmsg0    db    'These characters are in the first group of 256',0Dh,0Ah
  537. csmsg1    db    'These characters are in the second group of 256',0Dh,0Ah
  538. KeyMsg    db    0Dh,0Ah,'Press any key to continue ...',0Dh,0Ah
  539.